import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:interview/components/app/app_ripple_button.dart';
import 'package:interview/controller/navigation_controller.dart';
import 'package:interview/theme/app_colors.dart';

class PageNavBar extends StatelessWidget {
  final AppColors theme;
  final bool showTitle;
  final String title;
  final bool showRight;
  final Widget rightWidget;
  final bool showBorder;
  
  const PageNavBar({
    super.key, 
    required this.theme,
    required this.showTitle,
    required this.title, 
    required this.showRight,
    this.rightWidget = const Icon(Icons.add_outlined),
    this.showBorder = false,
  });
  
  @override
  Widget build(BuildContext context) {
    final navigation = Get.find<NavigationController>();
    return Container(
      width: double.infinity,
      decoration: BoxDecoration(
        color: theme.subjectPure,
        border: showBorder ? Border(bottom: BorderSide( color: theme.contrastMix3! , width: 0.5)) :null
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        mainAxisSize: MainAxisSize.min,
        children: [
          AppRippleButton(
            backgroundColor: theme.subjectPure!,
            splashColor:theme.contrastMix3!.withOpacity(0.2),
            highlightColor:theme.subjectMix1!.withOpacity(0.1),
            padding: EdgeInsets.all(16),
            onTap: () {
              navigation.back();
            },
            child: Icon(Icons.arrow_back_ios , size: 12,),
          ),

          if(showTitle)
          Text(title , style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold , color: theme.contrastMix3)),
          showRight ? 
          rightWidget: 
          SizedBox(width: 44,height: 44)
        ],
      ),
    );
  }
}